package org.project.programeditor.model.programming;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.boxlayout.widget.Widget;
import org.boxlayout.widget.base.ActionLabel;
import org.boxlayout.widget.base.Label;
import org.boxlayout.widget.base.Spacer;
import org.boxlayout.widget.container.Container;
import org.boxlayout.widget.container.Container.ContainerLayout;
import org.boxlayout.widget.event.ActionEvent;
import org.boxlayout.widget.event.ActionListener;
import org.boxlayout.widget.menu.Menu;

public class ProgrammingModel {

	Container container;
	Widget childContainer;
	Container menu;
	
	Log log = LogFactory.getLog(getClass());
	
	public ProgrammingModel() {
		container = new Container().setLayout(ContainerLayout.VERTICAL);
		//container.setColor(ColorEnum.DARKGRAY).setTextColor(ColorEnum.DARKGRAY);
		
		menu = menu();
		
		Widget headContainer = new Container().append(menu).append(new Label("{"));
		childContainer = new Container().setLayout(ContainerLayout.VERTICAL).setMinWidth(1f).setMinHeight(1f);
		Widget contentLayout = new Container().setLayout(ContainerLayout.HORIZONTAL).append(new Spacer(0.3f)).append(childContainer);
		Widget end = new Label("}");
		
		container.append(headContainer).append(new Spacer(0.1f)).append(contentLayout).append(new Spacer(0.1f)).append(end);
		
	}

	Container menu() {
		Menu menu=new Menu("Java");
		menu.append(new ActionLabel("[Add]").setOnClick(new ActionListener() {
			
			@Override
			public void action(Widget target,ActionEvent actionEvent) {
				Package p = new Package().setName("org.nameless");
				childContainer.append(p.getWidget());
			}
		}));
		menu.append(new ActionLabel("[edit]"));
		return menu;
	}
	
	public Widget getWidget() {
		return container;
	}
	
}
